package com.xl6667.controller;

import com.xl6667.domain.ResponseResult;
import com.xl6667.domain.entity.Tag;
import com.xl6667.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("content/tag")
public class TagController {
    @Autowired
    private TagService tagService;
    /**
     * 获取标签
     * @param pageSize 条数
     * @param pageNum 页码
     * @param name 标签名
     * @param remark 备注
     * @return
     */
    @GetMapping("/list")
    public ResponseResult getTagList(Integer pageSize,Integer pageNum,String name, String remark){
        return tagService.getTagList(pageSize,pageNum,name,remark);
    }

    /**
     * 修改标签回显功能
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ResponseResult getTag(@PathVariable Long id){
        return tagService.getTag(id);
    }
    @PutMapping
    public ResponseResult putTag(@RequestBody Tag tag){
        return tagService.putTag(tag);
    }

    /**
     * 添加标签
     * @param tag
     * @return
     */
    @PostMapping
    public ResponseResult addTag(@RequestBody Tag tag){
        return tagService.addTag(tag);
    }

    /**
     * 删除标签
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public ResponseResult delTag(@PathVariable List<Integer> id){
        return tagService.delTag(id);
    }

    @GetMapping("/listAllTag")
    public ResponseResult listAllTag(){
        return tagService.listAllTag();
    }

}
